package top.canyue.word_range_service.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import top.canyue.word_range.pojo.po.RelUserEvent;

@Mapper
public interface RelUserEventMapper extends BaseMapper<RelUserEvent> {

    @Insert("INSERT INTO rel_user_event(id, user_id, event_id, participate_time) " +
            "values(MD5(UUID()),#{userId},#{eventId},NOW())")
    Integer participateEvent(String userId, String eventId);

    @Insert("UPDATE rel_user_event SET complete_time = NOW() WHERE user_id = #{userId} AND event_id = #{eventId} " +
            "AND complete_time IS NULL ")
    Integer finishEvent(String userId, String eventId);
}
